from django.test import TestCase
import redis
# Create your tests here.


class RedisTestCase(TestCase):
    def setUp(self):
        pass

    def test_pool_redis(self):
        localhost = '47.103.7.159'
        port = '6379'
        poll = redis.ConnectionPool(host=localhost,
                           port=port,
                           password='maoandyou',
                           db=2)
        r = redis.Redis(connection_pool=poll)
        r.set('foo', 'bar')
        result = r.get('foo').decode('utf8')
        self.assertEqual(result, 'bar')

    def test_redis(self):
        localhost = '47.103.7.159'
        port = '6379'
        r = redis.Redis(
            host=localhost,
            port=port,
            password='maoandyou',
            db=2
        )
        r.set('foo','bar')
        result = r.get('foo').decode('utf8')
        self.assertEqual(result, 'bar')
